package com.anpy.security.security;

/**
 * Utility class to hold the current platform context in a ThreadLocal.
 * This allows us to access the current platform code throughout the request lifecycle.
 */
public class PlatformContextHolder {
    
    private static final ThreadLocal<String> PLATFORM_CONTEXT = new ThreadLocal<>();
    
    /**
     * Set the platform code for the current thread
     * 
     * @param platformCode The platform code to set
     */
    public static void setPlatformCode(String platformCode) {
        PLATFORM_CONTEXT.set(platformCode);
    }
    
    /**
     * Get the platform code for the current thread
     * 
     * @return The current platform code or null if not set
     */
    public static String getPlatformCode() {
        return PLATFORM_CONTEXT.get();
    }
    
    /**
     * Clear the platform code for the current thread
     */
    public static void clear() {
        PLATFORM_CONTEXT.remove();
    }
}
